package cn.liip.demo.controller;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import cn.liip.demo.properties.MyProperties1;
import cn.liip.demo.properties.MyProperties2;

@RequestMapping("/properties")
@RestController
public class PropertiesController {

	private static final Logger log = LoggerFactory.getLogger(PropertiesController.class);

	private final MyProperties1 myProperties1;

	private final MyProperties2 myProperties2;

	@Autowired
	public PropertiesController(MyProperties1 myProperties1, MyProperties2 myProperties2) {
		this.myProperties1 = myProperties1;
		this.myProperties2 = myProperties2;
	}

	/**
	 * 访问路径 : http://localhost:8080/chapter/properties/1
	 * 
	 * @return
	 */
	@GetMapping("/1")
	public MyProperties1 myProperties1() {
		log.info("=================================================================================================");
		log.info(myProperties1.toString());
		log.info("=================================================================================================");
		return myProperties1;
	}

	/**
	 * 访问路径 : http://localhost:8080/chapter/properties/2
	 * 
	 * @return
	 */
	@GetMapping("/2")
	public MyProperties2 myProperties2() {
		log.info("=================================================================================================");
		log.info(myProperties2.toString());
		log.info("=================================================================================================");
		return myProperties2;
	}
}